<!doctype html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>修改密码</title>
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--<meta name="format-detection" content="telephone = no" />-->
    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">
    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="修改密码" />
    <meta name="msapplication-TileColor" content="#090a0a">
    <link rel="stylesheet" href="__ROOT__/static/home/css/css_style.css">
    <link href="__ROOT__/static/home/css/userInfo/css/mui.min.css" rel="stylesheet"/>
    <link href="__ROOT__/static/home/css/userInfo/layer.mobile-v2.0/layer_mobile/need/layer.css" rel="stylesheet"/>
    <script src="__ROOT__/static/home/js/jquery-1.11.1.min.js"></script>
    <script src="http://www.veryhuo.com/uploads/Common/js/jQuery.md5.js"></script>
    <script src="__ROOT__/static/home/css/userInfo/layer.mobile-v2.0/layer_mobile/layer.js"></script>
    <link rel="stylesheet" href="__ROOT__/static/home/css/userInfo/css/top_nav.css" />

    <script>
        $(function () {
            $('#save').click(function(){
                //验证旧密码是否正确
                var oldC =$('.oldCheck').val();
                var oldP = $('.oldPassword').val();
                var oldP1 = $.md5(oldP);
                var p1=$('.password1').val();
                var p2=$('.password2').val();
                if(oldC!==oldP1){
                    layer.open({
                        content:'旧密码错误!'
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                }else if(p1==''&&p2==''){
                    layer.open({
                        content: '密码不能为空!'
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                }else if(p1!==p2){
                    layer.open({
                        content: '两次密码输入不同!'
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                }else{
                    //保存密码
                    var params ={};
                    params.password=$('.password1').val();
                    $.ajax({

                                cache:true,
                                type:'POST',
                                url:"{:url('home/Userinfo/savePassword')}" ,
                                data: params,
                                async:false,
                                success:function(data){
                                    if(data==1){
                                        layer.open({
                                            content: '修改成功'
                                            ,skin: 'msg'
                                            ,time: 2 //2秒后自动关闭
                                        });
                                    }else{
                                        layer.open({
                                            content: '修改失败'
                                            ,skin: 'msg'
                                            ,time: 2 //2秒后自动关闭
                                        });
                                    }
                                }

                            }
                    )
                }

            });

        })

    </script>
</head>
<body>
<div style="height: 50px;background-color: powderblue;">
    <div class="top_nav" style=""><a href="{:url('home/Userinfo/userInfo')}">< 返回</a></div>
    <div class="top_navC">修改密码</div>
    <div class="top_nav" id="save">保存</div>
</div>
<div class="member-top">
    <div class="header-r">
        <p>
            旧密码<input type="password" value="" class="oldPassword">
            <input type="hidden" value="{$row['user_pwd']}" class="oldCheck">
        </p>
    </div>
</div>
<div class="member-top">
    <div class="header-r">
        <p>新密码<input type="password" value="" class="password1"></p>
    </div>
</div>
<div class="member-top">
    <div class="header-r">
        <p>确认密码<input type="password" value="" class="password2"></p>
    </div>
</div>
</body>
</html>
